package com.koron.plan.web.repairplan.bean.vo;

import com.koron.plan.web.repairplan.bean.entity.PlanPackageBean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import javax.validation.Valid;
import java.io.*;
import java.util.Date;
import java.util.List;

/**
 * @author twcao
 * @title: PlanPackageVO
 * @projectName GDH_EAM_V2
 * @description: 检修计划包VO
 * @date 2021/9/1310:10
 */
@Data
@ApiModel("检修计划包VO")
@Slf4j
public class PlanPackageVO extends PlanPackageBean implements Cloneable {

    @Valid
    @ApiModelProperty("责任单位")
    private List<PlanPackageDeptVO> depts;

    /*************************** 前端传入   ******************************/
    @ApiModelProperty("计划起始时间-列表查询条件")
    private Date startTime;

    @ApiModelProperty("计划终止时间-列表查询条件")
    private Date endTime;
    /*************************** 前端传入   ******************************/

    /*************************** 后端返回   ******************************/
    @ApiModelProperty("当前节点名称")
    private String curNodeName;

    @ApiModelProperty("当前节点审批人姓名，多个之间，逗号分隔")
    private String curNodeUserNames;
    /*************************** 后端返回   ******************************/

    @Override
    public PlanPackageVO clone(){
        PlanPackageVO o = null;
        try{
            if (this != null){
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                ObjectOutputStream oos = new ObjectOutputStream(baos);
                oos.writeObject(this);
                oos.close();
                ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
                ObjectInputStream ois = new ObjectInputStream(bais);
                o = (PlanPackageVO) ois.readObject();
                ois.close();
            }
        } catch (IOException e){
            log.error(e.getMessage(), e);
        } catch (ClassNotFoundException e) {
            log.error(e.getMessage(), e);
        }
        return o;
    }
}
